//
//  ICSocketRequestManager.m
//  ICome
//
//  Created by zhangrongwu on 16/8/5.
//  Copyright © 2016年 iCom. All rights reserved.
//  所有请求 入口

#import "ICSocketRequestManager.h"
#import "ICAsyncSocketConfig.h"
#import "ICSyncManager.h"

@implementation ICSocketRequestManager
+(ICSocketRequestManager *)sharedInstance {
    static ICSocketRequestManager *instance = nil;
    static dispatch_once_t once;
    dispatch_once(&once, ^{
        instance = [[ICSocketRequestManager alloc] init];
    });
    return instance;
}

-(instancetype)init {
    if (self = [super init]) {
        [self checkNetworkStatus];
    }
    return self;
}

- (void)checkNetworkStatus {
    // 网络改变 重连
    [[AFNetworkReachabilityManager sharedManager] startMonitoring];
    [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        if (status != 0) {
            if (![ICTools stringEmpty:[ICTools getToken]]) {
                if (![[ICAsyncSocketManager sharedInstance] isConnected]) {
                    [[ICAsyncSocketManager sharedInstance] reconnectionSuccess:^{
                        [[ICAsyncSocketManager sharedInstance] reSendRequest];
                    } Failure:nil];
                }
            }
        } else {
            [ICSyncManager sharedInstance].syncLoadingStatus = ICSyncLoadingStatusNotNetWork;
        }
    }];
}



/************************************业***务***处***理********************************************/

/** 轻应用列表*/
-(void)requestAppListWithObject:(NSDictionary *)param
                        Success:(SocketSuccessCompletionHandle)success
                        Failure:(SocketFailureCompletionHandle)failure {
    NSDictionary *body = [self packageRequestObject:param Api:@"application/appList"];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

/** 应用搜索*/
-(void)requestSearchAppListWithObject:(NSDictionary *)param
                              Success:(SocketSuccessCompletionHandle)success
                              Failure:(SocketFailureCompletionHandle)failure {
    NSDictionary *body = [self packageRequestObject:param Api:@"application/searchAppList"];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

/** 应用关注*/
-(void)subAppWithObject:(NSDictionary *)param
                Success:(SocketSuccessCompletionHandle)success
                Failure:(SocketFailureCompletionHandle)failure {
    NSDictionary *body = [self packageRequestObject:param Api:@"application/subApp"];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

/** 取消关注应用*/
-(void)unSubAppWithObject:(NSDictionary *)param
                  Success:(SocketSuccessCompletionHandle)success
                  Failure:(SocketFailureCompletionHandle)failure {
    NSDictionary *body = [self packageRequestObject:param Api:@"application/unSubApp"];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

/** 拉取消息处理 mPull*/
- (void)mPullMessageWithObject:(id)param
                       Success:(SocketSuccessCompletionHandle)success
                       Failure:(SocketFailureCompletionHandle)failure {
    NSDictionary *body = [self packageLocationRequestObject:param Api:@"imserver/mpull"];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

/** 更新组信息*/
-(void)updateGroupInfoWithObject:(id)param
                         Success:(SocketSuccessCompletionHandle)success
                         Failure:(SocketFailureCompletionHandle)failure {
    NSDictionary *body = [self packageRequestObject:param Api:MESSAGE_GROUPINFO];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

- (void)groupInfoWithObject:(NSDictionary *)param
                    Success:(SocketSuccessCompletionHandle)success
                    Failure:(SocketFailureCompletionHandle)failure
{
    NSDictionary *body = [self packageRequestObject:param Api:MESSAGE_GROUPINFO];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

/** 通知消息*/
- (void)imServerPullWithObject:(id)param
                       Success:(SocketSuccessCompletionHandle)success
                       Failure:(SocketFailureCompletionHandle)failure {
    NSDictionary *body = [self packageLocationRequestObject:param Api:@"imserver/pull"];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

/** 送达号DirectMPull 同步*/
- (void)mPullDirectWithObject:(id)param
                      Success:(SocketSuccessCompletionHandle)success
                      Failure:(SocketFailureCompletionHandle)failure {
    NSDictionary *body = [self packageRequestObject:param Api:@"direct/mpulld"];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

/** grouplist */
- (void)updateGroupListWithObject:(id)param
                          Success:(SocketSuccessCompletionHandle)success
                          Failure:(SocketFailureCompletionHandle)failure {
    NSDictionary *body = [self packageLocationRequestObject:param Api:@"imserver/groupList"];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

/** directList */
- (void)updateDirectListWithObject:(id)param
                           Success:(SocketSuccessCompletionHandle)success
                           Failure:(SocketFailureCompletionHandle)failure {
    NSDictionary *body = [self packageLocationRequestObject:param Api:@"imserver/directList"];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

/** directInfo */
-(void)updateDirectInfoWithObject:(id)param
                          Success:(SocketSuccessCompletionHandle)success
                          Failure:(SocketFailureCompletionHandle)failure {
    NSDictionary *body = [self packageRequestObject:param Api:@"direct/directInfo"];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

/** CmdList */
-(void)updateCmdListWithObject:(id)param
                       Success:(SocketSuccessCompletionHandle)success
                       Failure:(SocketFailureCompletionHandle)failure {
    NSDictionary *body = [self packageLocationRequestObject:param Api:@"imserver/cmdList"];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

/** return cmd action */
- (void)confirmActionWithObject:(id)param {
    NSDictionary *body = [self packageActionRequestObject:param Api:@""];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
    }];
}

/** user info */
-(void)requestUserInfoWithObject:(NSDictionary *)param
                         Success:(SocketSuccessCompletionHandle)success
                         Failure:(SocketFailureCompletionHandle)failure {
    NSDictionary *body = [self packageRequestObject:param Api:@"contact/getEmployeeByEmployeeId"];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

-(void)getSubOrgAndSubEmpListWithObject:(NSDictionary *)param
                                Success:(SocketSuccessCompletionHandle)success
                                Failure:(SocketFailureCompletionHandle)failure {
    NSDictionary *body = [self packageRequestObject:param Api:CONTACT_ORG_LIST];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

//  根据oid获取我的部门
-(void)getOrgsByoIdWithObject:(NSDictionary *)param
                      Success:(SocketSuccessCompletionHandle)success
                      Failure:(SocketFailureCompletionHandle)failure{
    NSDictionary *body = [self packageRequestObject:param Api:@"contact/getOrgsByoId"];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

//  根据eid获取我的部门
-(void)getOrgsByeIdWithObject:(NSDictionary *)param
                      Success:(SocketSuccessCompletionHandle)success
                      Failure:(SocketFailureCompletionHandle)failure {
    NSDictionary *body = [self packageRequestObject:param Api:CONTACT_MDEP_LIST];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}


//  打开双人会话
- (void)createTwoGroupWithObject:(NSDictionary *)param
                         Success:(SocketSuccessCompletionHandle)success
                         Failure:(SocketFailureCompletionHandle)failure {
    NSDictionary *body = [self packageRequestObject:param Api:CreateTwoGroup];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

// 应用详情
-(void)getAppDetailWithObject:(NSDictionary *)param
                      Success:(SocketSuccessCompletionHandle)success
                      Failure:(SocketFailureCompletionHandle)failure {
    NSDictionary *body = [self packageRequestObject:param Api:@"application/getAppDetail"];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}


// 用户电话
-(void)updatePhoneWithObject:(NSDictionary *)param
                     Success:(SocketSuccessCompletionHandle)success
                     Failure:(SocketFailureCompletionHandle)failure {
    NSDictionary *body = [self packageRequestObject:param Api:@"contact/updatePhoneByEmployeeId"];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

// 全局免打扰 api
-(void)setGlobalBusyWithObject:(NSDictionary *)param
                       Success:(SocketSuccessCompletionHandle)success
                       Failure:(SocketFailureCompletionHandle)failure {
    NSDictionary *body = [self packageLocationRequestObject:param Api:COMMON_GLOBABUSY];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

// 获取忙时状态
-(void)getGlobalBusyWithObject:(NSDictionary *)param
                       Success:(SocketSuccessCompletionHandle)success
                       Failure:(SocketFailureCompletionHandle)failure {
    NSDictionary *body = [self packageLocationRequestObject:param Api:COMMON_GETGLOBUSY];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}


// 员工搜索 and 组织搜索 －>
-(void)contactSearchListWithObject:(NSDictionary *)param
                           Success:(SocketSuccessCompletionHandle)success
                           Failure:(SocketFailureCompletionHandle)failure {
    NSDictionary *body = [self packageRequestObject:param Api:APP_SEARCH_EMPL];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

// 员工搜索 or 组织搜索
-(void)searchEmpOROrgWithObject:(NSDictionary *)param
                        Success:(SocketSuccessCompletionHandle)success
                        Failure:(SocketFailureCompletionHandle)failure {
    NSDictionary *body = [self packageRequestObject:param Api:@"contact/searchEmpOROrg"];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}


// 获取tId的组员信息列表
-(void)getTeamEmployeListWithObject:(NSDictionary *)param
                            Success:(SocketSuccessCompletionHandle)success
                            Failure:(SocketFailureCompletionHandle)failure {
    NSDictionary *body = [self packageRequestObject:param Api:CONTACT_TEAMEMP_LIST];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}


// 获取团队列表
-(void)getTeamListWithObject:(NSDictionary *)param
                     Success:(SocketSuccessCompletionHandle)success
                     Failure:(SocketFailureCompletionHandle)failure {
    NSDictionary *body = [self packageRequestObject:param Api:CONTACT_TEAM_LIST];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}


- (void)recallMessageWithObject:(NSDictionary *)param
                        Success:(SocketSuccessCompletionHandle)success
                        Failure:(SocketFailureCompletionHandle)failure
{
    NSDictionary *body = [self packageRequestObject:param Api:MESSAGE_RECALLMSG];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

- (void)repullMessageWithObject:(NSDictionary *)param
                        Success:(SocketSuccessCompletionHandle)success
                        Failure:(SocketFailureCompletionHandle)failure
{
    NSDictionary *body = [self packageLocationRequestObject:param Api:MESSAGE_IMREVPULL];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

- (void)disbandGroupWithObject:(NSDictionary *)param
                       Success:(SocketSuccessCompletionHandle)success
                       Failure:(SocketFailureCompletionHandle)failure
{
    NSDictionary *body = [self packageRequestObject:param Api:CONTACT_BREAKGROUP];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

- (void)existGroupWithObject:(NSDictionary *)param
                     Success:(SocketSuccessCompletionHandle)success
                     Failure:(SocketFailureCompletionHandle)failure
{
    NSDictionary *body = [self packageRequestObject:param Api:CONTACT_EXITGROUP];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

- (void)groupBusyWithObject:(NSDictionary *)param
                    Success:(SocketSuccessCompletionHandle)success
                    Failure:(SocketFailureCompletionHandle)failure
{
    NSDictionary *body = [self packageLocationRequestObject:param Api:CONTACT_GROUPBUSY];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

- (void)appendUserWithObject:(NSDictionary *)param
                     Success:(SocketSuccessCompletionHandle)success
                     Failure:(SocketFailureCompletionHandle)failure
{
    NSDictionary *body = [self packageRequestObject:param Api:CONTACT_APPENDUSER];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

- (void)changeGroupNameWithObject:(NSDictionary *)param
                          Success:(SocketSuccessCompletionHandle)success
                          Failure:(SocketFailureCompletionHandle)failure
{
    NSDictionary *body = [self packageRequestObject:param Api:CONTACT_CHANGEGROUPNAME];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

- (void)kickGroupUserWithObject:(NSDictionary *)param
                        Success:(SocketSuccessCompletionHandle)success
                        Failure:(SocketFailureCompletionHandle)failure
{
    NSDictionary *body = [self packageRequestObject:param Api:CONTACT_KICKUSER];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

- (void)kickGroupUserArrayWithObject:(NSDictionary *)param
                        Success:(SocketSuccessCompletionHandle)success
                        Failure:(SocketFailureCompletionHandle)failure
{
    NSDictionary *body = [self packageRequestObject:param Api:CONTACT_KICKUSERS];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}


- (void)deliverListWithObject:(NSDictionary *)param
                      Success:(SocketSuccessCompletionHandle)success
                      Failure:(SocketFailureCompletionHandle)failure
{
    NSDictionary *body = [self packageRequestObject:param Api:Deliver_List];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

- (void)subDirectWithObject:(NSDictionary *)param
                    Success:(SocketSuccessCompletionHandle)success
                    Failure:(SocketFailureCompletionHandle)failure
{
    NSDictionary *body = [self packageRequestObject:param Api:Deliver_subDirect];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

- (void)voiceReadWithObject:(NSDictionary *)param
                    Success:(SocketSuccessCompletionHandle)success
                    Failure:(SocketFailureCompletionHandle)failure
{
    NSDictionary *body = [self packageRequestObject:param Api:MESSAGE_VOICEREADE];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

- (void)multGroupWithObject:(NSDictionary *)param
                    Success:(SocketSuccessCompletionHandle)success
                    Failure:(SocketFailureCompletionHandle)failure
{
    NSDictionary *body = [self packageRequestObject:param Api:CreateMultGroup];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

- (void)addNewsWithObject:(NSDictionary *)param
                  Success:(SocketSuccessCompletionHandle)success
                  Failure:(SocketFailureCompletionHandle)failure
{
    NSDictionary *body = [self packageRequestObject:param Api:Deliver_addCount];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

- (void)createOrgGroupWithObject:(NSDictionary *)param
                         Success:(SocketSuccessCompletionHandle)success
                         Failure:(SocketFailureCompletionHandle)failure
{
    NSDictionary *body = [self packageRequestObject:param Api:CreateOrgGroup];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

- (void)changeMasterWithObject:(NSDictionary *)param
                       Success:(SocketSuccessCompletionHandle)success
                       Failure:(SocketFailureCompletionHandle)failure
{
    NSDictionary *body = [self packageRequestObject:param Api:Message_changeGroupMaster];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

- (void)directBusyWithObject:(NSDictionary *)param
                     Success:(SocketSuccessCompletionHandle)success
                     Failure:(SocketFailureCompletionHandle)failure
{
    NSDictionary *body = [self packageRequestObject:param Api:Deliver_busy];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
    
}

- (void)searchDirectWithObject:(NSDictionary *)param
                       Success:(SocketSuccessCompletionHandle)success
                       Failure:(SocketFailureCompletionHandle)failure
{
    NSDictionary *body = [self packageRequestObject:param Api:Deliver_searchD];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

- (void)changeNickNameWithObject:(NSDictionary *)param
                         Success:(SocketSuccessCompletionHandle)success
                         Failure:(SocketFailureCompletionHandle)failure
{
    NSDictionary *body = [self packageRequestObject:param Api:ChangeNickName];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}


- (void)deliverRepullWithObject:(NSDictionary *)param
                        Success:(SocketSuccessCompletionHandle)success
                        Failure:(SocketFailureCompletionHandle)failure
{
    NSDictionary *body = [self packageRequestObject:param Api:Deliver_repull];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

- (void)directInfoWithObject:(NSDictionary *)param
                     Success:(SocketSuccessCompletionHandle)success
                     Failure:(SocketFailureCompletionHandle)failure
{
    NSDictionary *body = [self packageRequestObject:param Api:Deliver_directInfo];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}

- (void)groupReadWithObject:(NSDictionary *)param
                    Success:(SocketSuccessCompletionHandle)success
                    Failure:(SocketFailureCompletionHandle)failure
{
    NSDictionary *body = [self packageRequestObject:param Api:MESSAGE_updateGroupRead];
    [[ICSocketCommunicationManager sharedInstance] requestWithRequestType:SCRequestType_Normal requestBody:body Identifier:@"0" completion:^(id data, NSError *error, id other) {
        if (requestSuccess) {
            success(data);
        } else {
            failure(error, other);
        }
    }];
}






















/***************************************根据不同的服务器**************************************************/
/****************************************使用不同的命令***************************************************/
- (NSDictionary *)packageRequestObject:(id)object Api:(NSString *)api { // 7
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
    [dic setObject:[NSString stringWithFormat:@"%d", ICConnectCmdType_LongDistanceFunc] forKey:@"c"];
    [dic setObject:api forKey:@"p"];
    [dic setObject:object forKey:@"d"];
    return dic;
}

- (NSDictionary *)packageLocationRequestObject:(id)object Api:(NSString *)api { // 5
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
    [dic setObject:[NSString stringWithFormat:@"%d", ICConnectCmdType_LocFunc] forKey:@"c"];
    [dic setObject:api forKey:@"p"];
    [dic setObject:object forKey:@"d"];
    return dic;
}

- (NSDictionary *)packageActionRequestObject:(id)object Api:(NSString *)api { // 13
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
    [dic setObject:[NSString stringWithFormat:@"%d", ICConnectCmdType_ActionBack] forKey:@"c"];
    [dic setObject:api forKey:@"p"];
    [dic setObject:object forKey:@"d"];
    return dic;
}








@end
